package com.vincent.suchao.lcld;

import com.vincent.suchao.adapter.ContactsAdapter;
import com.vincent.suchao.adapter.NineMenuAdapter;
import com.vincent.suchao.entity.MyContacts;
import com.vincent.suchao.entity.MyContacts.ContactItem;
import com.vincent.suchao.entity.NineMenuItem;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class LXWM_Activity extends Activity implements OnClickListener, OnItemClickListener {
	private TextView tv_tittle;
	private Button b_back;
	private ListView lv_contact;
	private ContactsAdapter cAdapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_lxwm);
		init();
	}

	private void init() {
		tv_tittle = (TextView) findViewById(R.id.tv_tittle);
		tv_tittle.setText(getString(R.string.menu_com_lxwm));
		b_back = (Button) findViewById(R.id.b_back);
		b_back.setOnClickListener(this);
		lv_contact = (ListView) findViewById(R.id.lv_contact);
		cAdapter = new ContactsAdapter(this);
		lv_contact.setAdapter(cAdapter);
		lv_contact.setOnItemClickListener(this);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.gsjj, menu);
		return true;
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {

		case R.id.b_back:
			finish();
			break;
		default:
			break;
		}

	}

	private final String number = "028-62507360";

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

		RelativeLayout rl_inflater_contact = (RelativeLayout) arg1.findViewById(R.id.rl_inflater_contact);
		ContactItem menuItem = (ContactItem) rl_inflater_contact.getTag(R.id.rl_inflater_contact);
		if (menuItem.getResID() == R.drawable.lxwm1) {
			Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + number));
			startActivity(intent);
		}
	}

}
